package com.freewater.library.lending.book.infrastructure.springconfig;

import com.freewater.library.catalogue.model.BookRepository;
import com.freewater.library.lending.book.infrastructure.dao.BookInstanceDao;
import com.freewater.library.lending.book.infrastructure.repository.BookInstanceRepositoryImpl;
import com.freewater.library.lending.book.model.BookInstanceFactory;
import com.freewater.library.lending.book.model.BookInstanceRepository;
import com.freewater.library.lending.book.model.BookLendingService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BookInstanceConfiguration {

    @Bean
    public BookInstanceRepository bookInstanceRepository(BookInstanceDao bookInstanceDao) {
        return new BookInstanceRepositoryImpl(bookInstanceDao);
    }

    @Bean
    public BookInstanceFactory bookInstanceFactory(BookRepository bookRepository,
                                                   BookInstanceRepository bookInstanceRepository) {
        return new BookInstanceFactory(bookRepository, bookInstanceRepository);
    }

    @Bean
    public BookLendingService bookLendingService(BookInstanceRepository bookInstanceRepository) {
        return new BookLendingService(bookInstanceRepository);
    }
}
